package com.ipharma.application.services.transaccion;

/**
 * A Item class.
 * <P>
 * @author JorgE.H
 */
public class Item extends Object
{
  /**
   * Attributes
   */
  protected String code = "";
  protected String description = "";
  protected int quantity = 0;

  /**
   * Constructor
   */
  public Item()
  {
  }

  /**
   * Constructor
   * @param pDesc item description
   * @param pQty item quantity
   * @param pCode item code
   */
  public Item( String pDesc, int pQty, String pCode )
  {
    description = pDesc;
    quantity    = pQty;
    code        = pCode;
  }

  /**
   * Returns item description
   * @return the product description
   */
  public String getDescription()
  {
    return description;
  }

  /**
   * Sets item quantity
   * @param pQty new quantity
   */
  public void setQuantity( int pQty )
  {
    quantity = pQty;
  }

  /**
   * Returns item quantity
   * @return the product quantity
   */
  public int getQuantity()
  {
    return quantity;
  }

  /**
   * Returns item code
   * @return the product code
   */
  public String getCode()
  {
    return code;
  }

  /**
   * Returns a copy of current instance. Overrides equals() of Object
   * @return true if objects are equals in attributes, false otherwise
   */
  public boolean equals( Item pIte )
  {
    if ( pIte != null
      && pIte.getCode().equals( this.getCode() )
      && pIte.getDescription().equals( this.getDescription() ) )
      return true;
    return false;
  }

  /**
   * Returns a copy of current instance. Overrides clone() of Object
   * @return a cloned of this instance of Item
   */
  public Object clone()
  {
    return new Item( description, quantity, code );
  }

  /**
   * Overrides toString method in Object
   */
  public String toString()
  {
    return description;
  }
}